<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .fade-enter {
        transform: translateX(50px);
        opacity: 0;
      }
      .fade-enter-active,
      .fade-leave-active {
        transition: all 1s;
      }
      .fade-leave-to {
        transform: translateX(-50px);
        opacity: 0;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- 需要切换的元素外面要加一个transition标签, 有name属性 -->
      <button @click="show = !show">btn</button>
      <transition name="fade">
        <p v-if="show">hello</p>
      </transition>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          show: true,
        },
      });
    </script>
  </body>
</html>
